<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" errorPage="/error.jsp" isELIgnored="false" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %>
<%@ taglib uri="http://atleap.blandware.com/taglib" prefix="atleap" %>
<html:xhtml />

<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="CONTENT_LOCALES_COLLECTION_KEY" scope="page" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="MAIL_TEMPLATE_AVAIALABLE_VARIABLES_KEY" scope="page" />
<atleap:constants className="com.blandware.atleap.common.Constants" var="MIME_TYPE_PLAIN" />
<atleap:constants className="com.blandware.atleap.common.Constants" var="MIME_TYPE_HTML" />
<atleap:constants className="org.apache.struts.Globals" var="LOCALE_KEY" />
<atleap:constants className="com.blandware.atleap.webapp.taglib.core.content.editor.ContentEditorTag" var="EDITOR_TYPE_FCKEDITOR" />
<atleap:content identifier="information" ignore="true" uri="/core/mailTemplate/callUpdateBody"/>
<atleap:form action="core/mailTemplate/update" method="POST" validateOnSubmit="false">
	<div>
		<c:if test="${!empty sessionScope[pageScope.MAIL_TEMPLATE_AVAIALABLE_VARIABLES_KEY]}">
			<atleap:message key="core.mailTemplate.form.availableVariables" arg0="${sessionScope[pageScope.MAIL_TEMPLATE_AVAIALABLE_VARIABLES_KEY]}" /><br />
		</c:if>
		<br />
		<atleap:label property="body" styleClass="label" key="core.mailTemplate.form.body" />
	</div>
    <atleap:iterator items="${sessionScope[pageScope.CONTENT_LOCALES_COLLECTION_KEY]}" var="contentLocale">
		<div class="languageField">
			<atleap:fieldValue valueMap="${contentLocale.title}" var="languageTitle" />
			<c:if test="${empty languageTitle}">
				<c:set var="languageTitle" value="${contentLocale.identifier}" />
			</c:if>
			<atleap:message key="core.mailTemplate.form.language" />:&nbsp;${languageTitle}
		</div>
        <div>
			<c:choose>
				<c:when test="${mailTemplateForm.mimeType == pageScope.MIME_TYPE_PLAIN}">
					<html:textarea property="body(${contentLocale.identifier})" style="width: 95%; height: 250px;" />
				</c:when>
				<c:otherwise>
					<atleap:base var="baseHref" />
					<atleap:contentEditor type="${pageScope.EDITOR_TYPE_FCKEDITOR}" id="body(${contentLocale.identifier})" basePath="${ctxPath}/FCKeditor/" width="100%"
                            height="400px"  defaultLanguage="${sessionScope[pageScope.LOCALE_KEY].language}"  baseHref="${baseHref}"
                            fullPage="true"  editorAreaCss=""  editorAreaLanguage="${contentLocale.identifier}">
						${mailTemplateForm.bodyMap[contentLocale.identifier]}
					</atleap:contentEditor>
				</c:otherwise>
			</c:choose>
			<html:hidden property="from(${contentLocale.identifier})" />
			<html:hidden property="subject(${contentLocale.identifier})" />
			<html:hidden property="charset(${contentLocale.identifier})" />
        </div>
    </atleap:iterator>
    <html:hidden property="id" />
    <html:hidden property="mimeType" />
    <html:hidden property="version" />
    <atleap:cancel styleClass="button" type="back"><atleap:message key="core.commons.buttons.back" /></atleap:cancel>
    <atleap:submit styleClass="button"><atleap:message key="core.commons.buttons.update" /></atleap:submit>
    <atleap:cancel styleClass="button"><atleap:message key="core.commons.buttons.cancel" /></atleap:cancel>
</atleap:form>
